{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Use your annotated dataset"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "!pip install argilla"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import argilla as rg\n",
    "\n",
    "HF_TOKEN = \"...\"  # only for private spaces\n",
    "\n",
    "client = rg.Argilla(\n",
    "    api_url=\"...\",\n",
    "    api_key=\"...\",\n",
    "    headers={\"Authorization\": f\"Bearer {HF_TOKEN}\"},  # only for private spaces\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "dataset = client.datasets(name=\"ag_news\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "status_filter = rg.Query(filter=rg.Filter([(\"status\", \"==\", \"completed\")]))\n",
    "\n",
    "filtered_records = dataset.records(status_filter)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "filtered_records.to_datasets().push_to_hub(\"argilla/ag_news_annotated\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "dataset.to_hub(repo_id=\"argilla/ag_news_annotated\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "dataset = rg.Dataset.from_hub(repo_id=\"argilla/ag_news_annotated\")"
   ]
  }
 ],
 "metadata": {
  "colab": {
   "name": "Use your annotated dataset",
   "provenance": []
  },
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
